﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace Grid.Extensions
{
    public class DataGridViewTimeSpanCell : DataGridViewTextBoxCell
    {
        public DataGridViewTimeSpanCell() : base()
        {
        }

        public override void InitializeEditingControl(int rowIndex, object 
            initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
        {
            base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
            DataGridViewTimeSpanControl ctl = DataGridView.EditingControl as DataGridViewTimeSpanControl;
            ctl.Value = DateTime.Now.Date + (TimeSpan)this.Value;
        }

        public override Type EditType
        {
            get
            {
                return typeof(DataGridViewTimeSpanControl);
            }
        }

        public override Type ValueType
        {
            get
            {
                return typeof(TimeSpan);
            }
        }

        public override object DefaultNewRowValue
        {
            get
            {
                return new TimeSpan();
            }
        }

    }
}
